/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util.BD;

import java.sql.*;

/**
 *
 * @author Administrador
 */
public class Conexion {

    public static Connection con = null;
    public static Statement sentencia = null;
    public static ResultSet rs = null;
    private static String parametros;

    public static void conexion(String server, String db, String uid, String pwd) {
        try {
            parametros = "jdbc:odbc:Driver={SQL Server};"
                    + "server=" + server + ";"
                    + "DataBase=" + db + ";"
                    + "Uid=" + uid + ";"
                    + "Pwd=" + pwd + ";";
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection(parametros);
        } catch (SQLException e1) {
            javax.swing.JOptionPane.showMessageDialog(null, "Error en la Conexion al Motor SQL", "Error Conexion", 0);
            System.exit(0);
        } catch (Exception e2) {
            javax.swing.JOptionPane.showMessageDialog(null, "Error en la Conexion al Motor", "Error Conexion", 0);
            System.exit(0);
        }
    }
}
